package umt.cs.cs241.assignment3.r_3_13;

import java.util.Random;

public class ElementRemoval {

	private Integer [] array;
	
	public ElementRemoval(int elements){
		
		array = this.getRandomIntArray(elements);
		this.removeUntilEmpty(array);
	}
	
	public void removeUntilEmpty(Integer [] array){
		
		Random randomGen = new Random();
		boolean hasElements = true;
		
		
		for(int i = 0; i < array.length; i++){
			
			//If the element at i is not null, try to randomly make it null
			while(array[i] != null){
				array[randomGen.nextInt(array.length)] = null;
			}
			
			//Print the value of the elements
			for(int c = 0; c < array.length; c++){
				System.out.print(array[c] + " ");
			}
			System.out.println();
		}
			
		
	}
	
	/**
	 * Returns an array of random int values with an array size specified by the user.
	 * 
	 * @param arraySize The number of values a user wishes to place in the returned array.
	 * @return randomNumbers An array of random number values
	 */
	private Integer[] getRandomIntArray(int arraySize){
		
		Random randomGen = new Random();
		
		Integer [] randomNumbers = new Integer[arraySize];
		
		for(int i = 0; i < (arraySize - 1); i++){
			randomNumbers[i] = new Integer(randomGen.nextInt(25) + 1);
		}
		
		return randomNumbers;
		
	}
	
}
